package edu.ncsu.csc.csc454.project.gui.testing;

import java.awt.Graphics;
import java.awt.Graphics2D;

import javax.swing.JPanel;

@SuppressWarnings("serial")
public class TestPanel extends JPanel {

    private Graphics2D g;

    private int        xMid;
    private int        yMid;
    private int        radius;
    private double     skip;
    private int        dropPosition;

    public TestPanel() {
        setOpaque(false);
    }

    @Override
    public void paintComponent(Graphics gX) {
        super.paintComponent(gX);
        g = (Graphics2D) gX;

        g.drawOval(xMid - radius, yMid - radius, 2 * radius, 2 * radius);

        if (dropPosition == -1) {
            g.fillOval(xMid - 5, yMid - 5, 10, 10);
        } else {
            g.fillOval((int) (radius * Math.cos(skip * dropPosition) + xMid - 5), (int) (radius
                    * Math.sin(skip * dropPosition) + yMid - 5), 10, 10);
        }

    }

    public void refresh(int xMid, int yMid, double radius, double skip, int dropPosition) {
        this.xMid = xMid;
        this.yMid = yMid;
        this.radius = (int) radius;
        this.skip = skip;
        this.dropPosition = dropPosition;
        repaint();
    }
}
